package com.xinzhidi.web.balancecontrol.controller;


import com.xinzhidi.common.core.controller.BaseController;
import com.xinzhidi.common.core.domain.AjaxResult;
import com.xinzhidi.common.core.page.TableDataInfo;
import com.xinzhidi.web.balancecontrol.domain.po.BalanceControlPo;
import com.xinzhidi.web.balancecontrol.domain.po.LockPo;
import com.xinzhidi.web.balancecontrol.domain.vo.ControlVo;
import com.xinzhidi.web.balancecontrol.service.BalanceControlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 平衡调控
 *
 * @author cx
 * @date 2023-06-30
 */
@RestController
@Api(tags = "平衡调控")
@RequestMapping("/balanceControl")
@RequiredArgsConstructor
public class BalanceControlController extends BaseController {

    private final BalanceControlService balanceControlService;

    @ApiOperation("平衡调控-小区列表")
    @PostMapping("/listPlot")
    public TableDataInfo<ControlVo> listPlot(@Validated @RequestBody BalanceControlPo po) {
        startPagePost(po);
        return balanceControlService.listPlot(po);
    }

    @ApiOperation("平衡调控-楼栋列表")
    @PostMapping("/listBuild")
    public TableDataInfo<ControlVo> listBuild(@Validated @RequestBody BalanceControlPo po) {
        startPagePost(po);
        return balanceControlService.listBuild(po);
    }

    @ApiOperation("平衡调控-单元列表")
    @PostMapping("/listBuildUnit")
    public TableDataInfo<ControlVo> listBuildUnit(@Validated @RequestBody BalanceControlPo po) {
        startPagePost(po);
        return balanceControlService.listBuildUnit(po);
    }

    @ApiOperation("平衡调控-住户列表")
    @PostMapping("/listHousehold")
    public TableDataInfo<ControlVo> listHousehold(@Validated @RequestBody BalanceControlPo po) {
        startPagePost(po);
        return balanceControlService.listHousehold(po);
    }


    @ApiOperation("平衡调控-锁定/解锁")
    @PostMapping("/lockOrUnlock")
    public AjaxResult lockOrUnlock(@Validated @RequestBody LockPo po) {
        balanceControlService.lockOrUnlock(po);
        return AjaxResult.success();
    }

}
